<?php

namespace Api\Model;


class ExamScoreModel extends BaseModel{

	
	public function getByMidAndUid($uid, $mids)
	{
		if (!$uid || count($mids) == 0) {
            return ['success' => FALSE, '参数错误'];
        }

        // todo 考虑添加缓存机制 ，但是这张表又读又写 不好分离
        $mid_score_items = $this->where(['uid' => $uid, 'mid' => ['IN', implode(',', $mids)]])->select();
        return $mid_score_items;
	}

	public function getByUidAndCid($uid, $cid)
	{
		if (!$uid || !$cid) {
            return ['success' => FALSE, '参数错误'];
        }

        $score_items_arr = $this->where(['uid' => $uid, 'cid' => $cid])->order('score desc')->field('score')->select();

        return $score_items_arr;
	}

	public function listByCid($cid, $uid)
	{
		if (!$cid) {
            return ['success' => FALSE, '参数错误'];
        }

        $exam_items_arr = $this->where(['uid' => $uid, 'cid' => $cid])->select();

        return $exam_items_arr;
	}
}